home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / gnu / a2_0bEmacs_bin.lha / Emacs-19.25 / info / emacs-2 (.txt) < prev    next >
GNU Info File  |  1992-02-21  |  49KB  |  862 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.43 from the
  2. input file emacs.tex.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.
  5.    Permission is granted to make and distribute verbatim copies of
  6. this manual provided the copyright notice and this permission notice
  7. are preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  11. General Public License" are included exactly as in the original, and
  12. provided that the entire resulting derived work is distributed under
  13. the terms of a permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the sections entitled "The GNU Manifesto",
  17. "Distribution" and "GNU General Public License" may be included in a
  18. translation approved by the author instead of in the original English.
  19. File: emacs,  Node: Commands,  Next: Entering Emacs,  Prev: Keys,  Up: Top
  20. Keys and Commands
  21. =================
  22.    This manual is full of passages that tell you what particular keys
  23. do.  But Emacs does not assign meanings to keys directly.  Instead,
  24. Emacs assigns meanings to "functions", and then gives keys their
  25. meanings by "binding" them to functions.
  26.    A function is a Lisp object that can be executed as a program. 
  27. Usually it is a Lisp symbol which has been given a function
  28. definition; every symbol has a name, usually made of a few English
  29. words separated by dashes, such as `next-line' or `forward-word'.  It
  30. also has a "definition" which is a Lisp program; this is what makes
  31. the function do what it does.  Only some functions can be the bindings
  32. of keys; these are functions whose definitions use `interactive' to
  33. specify how to call them interactively.  Such functions are called
  34. "commands", and their names are "command names".  More information on
  35. this subject will appear in the GNU Emacs Lisp Manual (which is not
  36. yet written).
  37.    The bindings between keys and functions are recorded in various
  38. tables called "keymaps".  *Note Keymaps::.
  39.    When we say that "`C-n' moves down vertically one line" we are
  40. glossing over a distinction that is irrelevant in ordinary use but is
  41. vital in understanding how to customize Emacs.  It is the function
  42. `next-line' that is programmed to move down vertically.  `C-n' has
  43. this effect because it is bound to that function.  If you rebind `C-n'
  44. to the function `forward-word' then `C-n' will move forward by words
  45. instead.  Rebinding keys is a common method of customization.
  46.    In the rest of this manual, we usually ignore this subtlety to keep
  47. things simple.  To give the customizer the information he needs, we
  48. state the name of the command which really does the work in parentheses
  49. after mentioning the key that runs it.  For example, we will say that
  50. "The command `C-n' (`next-line') moves point vertically down," meaning
  51. that `next-line' is a command that moves vertically down and `C-n' is
  52. a key that is standardly bound to it.
  53.    While we are on the subject of information for customization only,
  54. it's a good time to tell you about "variables".  Often the description
  55. of a command will say, "To change this, set the variable `mumble-foo'."
  56. A variable is a name used to remember a value.  Most of the variables
  57. documented in this manual exist just to facilitate customization: some
  58. command or other part of Emacs examines the variable and behaves
  59. differently accordingly.  Until you are interested in customizing, you
  60. can ignore the information about variables.  When you are ready to be
  61. interested, read the basic information on variables, and then the
  62. information on individual variables will make sense.  *Note
  63. Variables::.
  64. File: emacs,  Node: Entering Emacs,  Next: Exiting,  Prev: Commands,  Up: Top
  65. Entering and Exiting Emacs
  66. **************************
  67.    The usual way to invoke Emacs is just to type `emacs RET' at the
  68. shell.  Emacs clears the screen and then displays an initial advisor
  69. message and copyright notice.  You can begin typing Emacs commands
  70. immediately afterward.
  71.    Some operating systems insist on discarding all type-ahead when
  72. Emacs starts up; they give Emacs no way to prevent this.  Therefore,
  73. it is wise to wait until Emacs clears the screen before typing your
  74. first editing command.
  75.    Before Emacs reads the first command, you have not had a chance to
  76. give a command to specify a file to edit.  But Emacs must always have
  77. a current buffer for editing.  In an attempt to do something useful,
  78. Emacs presents a buffer named `*scratch*' which is in Lisp Interaction
  79. mode; you can use it to type Lisp expressions and evaluate them, or
  80. you can ignore that capability and simply doodle.  (You can specify a
  81. different major mode for this buffer by setting the variable
  82. `initial-major-mode' in your init file.  *Note Init File::.)
  83.    It is also possible to specify files to be visited, Lisp files to be
  84. loaded, and functions to be called, by giving Emacs arguments in the
  85. shell command line.  *Note Command Switches::.
  86. File: emacs,  Node: Exiting,  Next: Command Switches,  Prev: Entering Emacs,  Up: Top
  87. Exiting Emacs
  88. =============
  89.    There are two commands for exiting Emacs because there are two
  90. kinds of exiting: "suspending" Emacs and "killing" Emacs. 
  91. "Suspending" means stopping Emacs temporarily and returning control to
  92. its superior (usually the shell), allowing you to resume editing later
  93. in the same Emacs job, with the same files, same kill ring, same undo
  94. history, and so on.  This is the usual way to exit.  "Killing" Emacs
  95. means destroying the Emacs job.  You can run Emacs again later, but
  96. you will get a fresh Emacs; there is no way to resume the same editing
  97. session after it has been killed.
  98. `C-z'
  99.      Suspend Emacs (`suspend-emacs').
  100. `C-x C-c'
  101.      Kill Emacs (`save-buffers-kill-emacs').
  102.    To suspend Emacs, type `C-z' (`suspend-emacs').  This takes you
  103. back to the shell from which you invoked Emacs.  You can resume Emacs
  104. with the command `%emacs' if you are using the C shell.
  105.    On systems that do not permit programs to be suspended, `C-z' runs
  106. an inferior shell that communicates directly with the terminal, and
  107. Emacs waits until you exit the subshell.  The only way on these
  108. systems to get back to the shell from which Emacs was run (to log out,
  109. for example) is to kill Emacs.  `C-d' or `exit' are typical commands
  110. to exit a subshell.
  111.    To kill Emacs, type `C-x C-c' (`save-buffers-kill-emacs').  A
  112. two-character key is used for this to make it harder to type.  Unless a
  113. numeric argument is used, this command first offers to save any
  114. modified buffers.  If you do not save them all, it asks for
  115. reconfirmation with `yes' before killing Emacs, since any changes not
  116. saved before that will be lost forever.  Also, if any subprocesses are
  117. still running, `C-x C-c' asks for confirmation about them, since
  118. killing Emacs will kill the subprocesses immediately.
  119.    In most programs running on Unix, certain characters may instantly
  120. suspend or kill the program.  (In Berkeley Unix these characters are
  121. normally `C-z' and `C-c'.)  This Unix feature is turned off while you
  122. are in Emacs.  The meanings of `C-z' and `C-x C-c' as keys in Emacs
  123. were inspired by the standard Berkeley Unix meanings of `C-z' and
  124. `C-c', but that is their only relationship with Unix.  You could
  125. customize these keys to do anything (*note Keymaps::.).
  126. File: emacs,  Node: Command Switches,  Next: Basic,  Prev: Exiting,  Up: Top
  127. Command Line Switches and Arguments
  128. ===================================
  129.    GNU Emacs supports command line arguments to request various actions
  130. when invoking Emacs.  These are for compatibility with other editors
  131. and for sophisticated activities.  They are not needed for ordinary
  132. editing with Emacs, so new users can skip this section.
  133.    You may be used to using command line arguments with other editors
  134. to specify which file to edit.  That's because many other editors are
  135. designed to be started afresh each time you want to edit.  You edit
  136. one file and then exit the editor.  The next time you want to edit
  137. either another file or the same one, you must run the editor again. 
  138. With these editors, it makes sense to use a command line argument to
  139. say which file to edit.
  140.    The recommended way to use GNU Emacs is to start it only once, just
  141. after you log in, and do all your editing in the same Emacs process. 
  142. Each time you want to edit a different file, you visit it with the
  143. existing Emacs, which eventually comes to have many files in it ready
  144. for editing.  Usually you do not kill the Emacs until you are about to
  145. log out.
  146.    When files are nearly always read by typing commands to an editor
  147. that is already running, command line arguments for specifying a file
  148. when the editor is started are seldom needed.
  149.    Emacs accepts command-line arguments that specify files to visit,
  150. functions to call, and other activities and operating modes.
  151.    The command arguments are processed in the order they appear in the
  152. command argument list; however, certain arguments (the ones in the
  153. second table) must be at the front of the list if they are used.
  154.    Here are the arguments allowed:
  155. `FILE'
  156.      Visit FILE using `find-file'.  *Note Visiting::.
  157. `+LINENUM FILE'
  158.      Visit FILE using `find-file', then go to line number LINENUM in
  159.      it.
  160. `-l FILE'
  161. `-load FILE'
  162.      Load a file FILE of Lisp code with the function `load'.  *Note
  163.      Lisp Libraries::.
  164. `-f FUNCTION'
  165. `-funcall FUNCTION'
  166.      Call Lisp function FUNCTION with no arguments.
  167. `-i FILE'
  168. `-insert FILE'
  169.      Insert the contents of FILE into the current buffer.  This is
  170.      like what `M-x insert-buffer' does; *Note Misc File Ops::.
  171. `-kill'
  172.      Exit from Emacs without asking for confirmation.
  173.    The remaining switches are recognized only at the beginning of the
  174. command line.  If more than one of them appears, they must appear in
  175. the order that they appear in this table.
  176. `-t DEVICE'
  177.      Use DEVICE as the device for terminal input and output.
  178. `-d DISPLAY'
  179.      When running with the X window system, use the display named
  180.      DISPLAY to make the window that serves as Emacs's terminal.
  181. `-batch'
  182.      Run Emacs in "batch mode", which means that the text being edited
  183.      is not displayed and the standard Unix interrupt characters such
  184.      as `C-z' and `C-c' continue to have their normal effect.  Emacs
  185.      in batch mode outputs to `stdout' only what would normally be
  186.      printed in the echo area under program control.
  187.      Batch mode is used for running programs written in Emacs Lisp from
  188.      shell scripts, makefiles, and so on.  Normally the `-l' switch or
  189.      `-f' switch will be used as well, to invoke a Lisp program to do
  190.      the batch processing.
  191.      `-batch' implies `-q' (do not load an init file).  It also causes
  192.      Emacs to kill itself after all command switches have been
  193.      processed.  In addition, auto-saving is not done except in
  194.      buffers for which it has been explicitly requested.
  195. `-no-init-file'
  196.      Do not load your Emacs init file `~/.emacs'.
  197. `-u USER'
  198. `-user USER'
  199.      Load USER's Emacs init file `~USER/.emacs' instead of your own.
  200.    Note that the init file can get access to the command line argument
  201. values as the elements of a list in the variable `command-line-args'. 
  202. (The arguments in the second table above will already have been
  203. processed and will not be in the list.)  The init file can override
  204. the normal processing of the other arguments by setting this variable.
  205.    One way to use command switches is to visit many files
  206. automatically:
  207.      emacs *.c
  208. passes each `.c' file as a separate argument to Emacs, so that Emacs
  209. visits each file (*note Visiting::.).
  210.    Here is an advanced example that assumes you have a Lisp program
  211. file called `hack-c-program.el' which, when loaded, performs some
  212. useful operation on current buffer, expected to be a C program.
  213.      emacs -batch foo.c -l hack-c-program -f save-buffer -kill > log
  214. Here Emacs is told to visit `foo.c', load `hack-c-program.el' (which
  215. makes changes in the visited file), save `foo.c' (note that
  216. `save-buffer' is the function that `C-x C-s' is bound to), and then
  217. exit to the shell that this command was done with.  `-batch'
  218. guarantees there will be no problem redirecting output to `log',
  219. because Emacs will not assume that it has a display terminal to work
  220. with.
  221. File: emacs,  Node: Basic,  Next: Undo,  Prev: Command Switches,  Up: Top
  222. Basic Editing Commands
  223. **********************
  224.    We now give the basics of how to enter text, make corrections, and
  225. save the text in a file.  If this material is new to you, you might
  226. learn it more easily by running the Emacs learn-by-doing tutorial.  To
  227. do this, type `Control-h t' (`help-with-tutorial').
  228. Inserting Text
  229. ==============
  230.    To insert printing characters into the text you are editing, just
  231. type them.  This inserts the character into the buffer at the cursor
  232. (that is, at "point"; *note Point::.).  The cursor moves forward.  Any
  233. characters after the cursor move forward too.  If the text in the
  234. buffer is `FOOBAR', with the cursor before the `B', then if you type
  235. `XX', you get `FOOXXBAR', with the cursor still before the `B'.
  236.    To "delete" text you have just inserted, use DEL.  DEL deletes the
  237. character BEFORE the cursor (not the one that the cursor is on top of
  238. or under; that is the character AFTER the cursor).  The cursor and all
  239. characters after it move backwards.  Therefore, if you type a printing
  240. character and then type DEL, they cancel out.
  241.    To end a line and start typing a new one, type RET.  This inserts a
  242. newline character in the buffer.  If point is in the middle of a line,
  243. RET splits the line.  Typing DEL when the cursor is at the beginning
  244. of a line rubs out the newline before the line, thus joining the line
  245. with the preceding line.
  246.    Emacs will split lines automatically when they become too long, if
  247. you turn on a special mode called "Auto Fill" mode.  *Note Filling::,
  248. for how to use Auto Fill mode.
  249.    Customization information: DEL in most modes runs the command named
  250. `delete-backward-char'; RET runs the command `newline', and
  251. self-inserting printing characters run the command `self-insert',
  252. which inserts whatever character was typed to invoke it.  Some major
  253. modes rebind DEL to other commands.
  254.    Direct insertion works for printing characters and SPC, but other
  255. characters act as editing commands and do not insert themselves.  If
  256. you need to insert a control character or a character whose code is
  257. above 200 octal, you must "quote" it by typing the character
  258. `control-q' (`quoted-insert') first.  There are two ways to use `C-q':
  259.    * `Control-q' followed by any non-graphic character (even `C-g')
  260.      inserts that character.
  261.    * `Control-q' followed by three octal digits inserts the character
  262.      with the specified character code.
  263. A numeric argument to `C-q' specifies how many copies of the quoted
  264. character should be inserted (*note Arguments::.).
  265.    If you prefer to have text characters replace (overwrite) existing
  266. text rather than shove it to the right, you can enable Overwrite mode,
  267. a minor mode.  *Note Minor Modes::.
  268. Changing the Location of Point
  269. ==============================
  270.    To do more than insert characters, you have to know how to move
  271. point (*note Point::.).  Here are a few of the commands for doing that.
  272. `C-a'
  273.      Move to the beginning of the line (`beginning-of-line').
  274. `C-e'
  275.      Move to the end of the line (`end-of-line').
  276. `C-f'
  277.      Move forward one character (`forward-char').
  278. `C-b'
  279.      Move backward one character (`backward-char').
  280. `M-f'
  281.      Move forward one word (`forward-word').
  282. `M-b'
  283.      Move backward one word (`backward-word').
  284. `C-n'
  285.      Move down one line, vertically (`next-line').  This command
  286.      attempts to keep the horizontal position unchanged, so if you
  287.      start in the middle of one line, you end in the middle of the
  288.      next.  When on the last line of text, `C-n' creates a new line
  289.      and moves onto it.
  290. `C-p'
  291.      Move up one line, vertically (`previous-line').
  292. `C-l'
  293.      Clear the screen and reprint everything (`recenter').  Text moves
  294.      on the screen to bring point to the center of the window.
  295. `M-r'
  296.      Move point to left margin on the line halfway down the screen or
  297.      window (`move-to-window-line').  Text does not move on the
  298.      screen.  A numeric argument says how many screen lines down from
  299.      the top of the window (zero for the top).  A negative argument
  300.      counts from the bottom (-1 for the bottom).
  301. `C-t'
  302.      Transpose two characters, the ones before and after the cursor
  303.      (`transpose-chars').
  304. `M-<'
  305.      Move to the top of the buffer (`beginning-of-buffer').  With
  306.      numeric argument N, move to N/10 of the way from the top.  *Note
  307.      Arguments::, for more information on numeric arguments.
  308. `M->'
  309.      Move to the end of the buffer (`end-of-buffer').
  310. `M-x goto-char'
  311.      Read a number N and move cursor to character number N.  Position
  312.      1 is the beginning of the buffer.
  313. `M-x goto-line'
  314.      Read a number N and move cursor to line number N.  Line 1 is the
  315.      beginning of the buffer.
  316. `C-x C-n'
  317.      Use the current column of point as the "semipermanent goal
  318.      column" for `C-n' and `C-p' (`set-goal-column').  Henceforth,
  319.      those commands always move to this column in each line moved
  320.      into, or as close as possible given the contents of the line. 
  321.      This goal column remains in effect until canceled.
  322. `C-u C-x C-n'
  323.      Cancel the goal column.  Henceforth, `C-n' and `C-p' once again
  324.      try to avoid changing the horizontal position, as usual.
  325.    If you set the variable `track-eol' to a non-`nil' value, then
  326. `C-n' and `C-p' when at the end of the starting line move to the end
  327. of the line.  Normally, `track-eol' is `nil'.
  328. Erasing Text
  329. ============
  330. `DEL'
  331.      Delete the character before the cursor (`delete-backward-char').
  332. `C-d'
  333.      Delete the character after the cursor (`delete-char').
  334. `C-k'
  335.      Kill to the end of the line (`kill-line').
  336. `M-d'
  337.      Kill forward to the end of the next word (`kill-word').
  338. `M-DEL'
  339.      Kill back to the beginning of the previous word
  340.      (`backward-kill-word').
  341.    You already know about the DEL key which deletes the character
  342. before the cursor.  Another key, `Control-d', deletes the character
  343. after the cursor, causing the rest of the text on the line to shift
  344. left.  If `Control-d' is typed at the end of a line, that line and the
  345. next line are joined together.
  346.    To erase a larger amount of text, use the `Control-k' key, which
  347. kills a line at a time.  If `C-k' is done at the beginning or middle of
  348. a line, it kills all the text up to the end of the line.  If `C-k' is
  349. done at the end of a line, it joins that line and the next line.
  350.    *Note Killing::, for more flexible ways of killing text.
  351. Files
  352. =====
  353.    The commands above are sufficient for creating and altering text in
  354. an Emacs buffer; the more advanced Emacs commands just make things
  355. easier.  But to keep any text permanently you must put it in a "file".
  356.  Files are named units of text which are stored by the operating
  357. system for you to retrieve later by name.  To look at or use the
  358. contents of a file in any way, including editing the file with Emacs,
  359. you must specify the file name.
  360.    Consider a file named `/usr/rms/foo.c'.  In Emacs, to begin editing
  361. this file, type
  362.      C-x C-f /usr/rms/foo.c RET
  363. Here the file name is given as an "argument" to the command `C-x C-f'
  364. (`find-file').  That command uses the "minibuffer" to read the
  365. argument, and you type RET to terminate the argument (*note
  366. Minibuffer::.).
  367.    Emacs obeys the command by "visiting" the file: creating a buffer,
  368. copying the contents of the file into the buffer, and then displaying
  369. the buffer for you to edit.  You can make changes in it, and then
  370. "save" the file by typing `C-x C-s' (`save-buffer').  This makes the
  371. changes permanent by copying the altered contents of the buffer back
  372. into the file `/usr/rms/foo.c'.  Until then, the changes are only
  373. inside your Emacs, and the file `foo.c' is not changed.
  374.    To create a file, just visit the file with `C-x C-f' as if it
  375. already existed.  Emacs will make an empty buffer in which you can
  376. insert the text you want to put in the file.  When you save your text
  377. with `C-x C-s', the file will be created.
  378.    Of course, there is a lot more to learn about using files.  *Note
  379. Files::.
  380.    If you forget what a key does, you can find out with the Help
  381. character, which is `C-h'.  Type `C-h k' followed by the key you want
  382. to know about; for example, `C-h k C-n' tells you all about what `C-n'
  383. does.  `C-h' is a prefix key; `C-h k' is just one of its subcommands
  384. (the command `describe-key').  The other subcommands of `C-h' provide
  385. different kinds of help.  Type `C-h' three times to get a description
  386. of all the help facilities.  *Note Help::.
  387. * Menu:
  388. * Blank Lines::        Commands to make or delete blank lines.
  389. * Continuation Lines:: Lines too wide for the screen.
  390. * Position Info::      What page, line, row, or column is point on?
  391. * Arguments::           Numeric arguments for repeating a command.
  392. File: emacs,  Node: Blank Lines,  Next: Continuation Lines,  Prev: Basic,  Up: Basic
  393. Blank Lines
  394. ===========
  395.    Here are special commands and techniques for putting in and taking
  396. out blank lines.
  397. `C-o'
  398.      Insert one or more blank lines after the cursor (`open-line').
  399. `C-x C-o'
  400.      Delete all but one of many consecutive blank lines
  401.      (`delete-blank-lines').
  402.    When you want to insert a new line of text before an existing line,
  403. you can do it by typing the new line of text, followed by RET. 
  404. However, it may be easier to see what you are doing if you first make
  405. a blank line and then insert the desired text into it.  This is easy
  406. to do using the key `C-o' (`open-line'), which inserts a newline after
  407. point but leaves point in front of the newline.  After `C-o', type the
  408. text for the new line.  `C-o F O O' has the same effect as `F O O
  409. RET', except for the final location of point.
  410.    You can make several blank lines by typing `C-o' several times, or
  411. by giving it an argument to tell it how many blank lines to make. 
  412. *Note Arguments::, for how.
  413.    If you have many blank lines in a row and want to get rid of them,
  414. use `C-x C-o' (`delete-blank-lines').  When point is on a blank line
  415. which is adjacent to at least one other blank line, `C-x C-o' deletes
  416. all but one of the consecutive blank lines, leaving exactly one.  With
  417. point on a blank line with no other blank line adjacent to it, the
  418. sole blank line is deleted, leaving none.  When point is on a nonblank
  419. line, `C-x C-o' deletes any blank lines following that nonblank line.
  420. File: emacs,  Node: Continuation Lines,  Next: Position Info,  Prev: Blank Lines,  Up: Basic
  421. Continuation Lines
  422. ==================
  423.    If you add too many characters to one line, without breaking it
  424. with a RET, the line will grow to occupy two (or more) lines on the
  425. screen, with a `\' at the extreme right margin of all but the last of
  426. them.  The `\' says that the following screen line is not really a
  427. distinct line in the text, but just the "continuation" of a line too
  428. long to fit the screen.  Sometimes it is nice to have Emacs insert
  429. newlines automatically when a line gets too long; for this, use Auto
  430. Fill mode (*note Filling::.).
  431.    Instead of continuation, long lines can be displayed by
  432. "truncation".  This means that all the characters that do not fit in
  433. the width of the screen or window do not appear at all.  They remain
  434. in the buffer, temporarily invisible.  `$' is used in the last column
  435. instead of `\' to inform you that truncation is in effect.
  436.    Continuation can be turned off for a particular buffer by setting
  437. the variable `truncate-lines' to non-`nil' in that buffer.  Truncation
  438. instead of continuation also happens whenever horizontal scrolling is
  439. in use, and optionally whenever side-by-side windows are in use (*note
  440. Windows::.).  Altering the value of `truncate-lines' makes it local to
  441. the current buffer; until that time, the default value is in effect. 
  442. The default is initially `nil'.  *Note Locals::.
  443. File: emacs,  Node: Position Info,  Next: Arguments,  Prev: Continuation Lines,  Up: Basic
  444. Cursor Position Information
  445. ===========================
  446.    If you are accustomed to other display editors, you may be
  447. surprised that Emacs does not always display the page number or line
  448. number of point in the mode line.  This is because the text is stored
  449. in a way that makes it difficult to compute this information. 
  450. Displaying them all the time would be intolerably slow.  They are not
  451. needed very often in Emacs anyway, but there are commands to compute
  452. them and print them.
  453. `M-x what-page'
  454.      Print page number of point, and line number within page.
  455. `M-x what-line'
  456.      Print line number of point in the buffer.
  457. `M-='
  458.      Print number of lines in the current region
  459.      (`count-lines-region').
  460. `C-x ='
  461.      Print character code of character after point, character position
  462.      of point, and column of point (`what-cursor-position').
  463.    There are two commands for printing line numbers.  `M-x what-line'
  464. counts lines from the beginning of the file and prints the line number
  465. point is on.  The first line of the file is line number 1.  These
  466. numbers can be used as arguments to `M-x goto-line'.  By contrast, `M-x
  467. what-page' counts pages from the beginning of the file, and counts
  468. lines within the page, printing both of them.  *Note Pages::.
  469.    While on this subject, we might as well mention `M-='
  470. (`count-lines-region'), which prints the number of lines in the region
  471. (*note Mark::.).  *Note Pages::, for the command `C-x l' which counts
  472. the lines in the current page.
  473.    The command `C-x =' (`what-cursor-position') can be used to find out
  474. the column that the cursor is in, and other miscellaneous information
  475. about point.  It prints a line in the echo area that looks like this:
  476.      Char: x (0170)  point=65986 of 563027(12%)  x=44
  477. (In fact, this is the output produced when point is before the `x=44'
  478. in the example.)
  479.    The two values after `Char:' describe the character following point,
  480. first by showing it and second by giving its octal character code.
  481.    `point=' is followed by the position of point expressed as a
  482. character count.  The front of the buffer counts as position 1, one
  483. character later as 2, and so on.  The next, larger number is the total
  484. number of characters in the buffer.  Afterward in parentheses comes
  485. the position expressed as a percentage of the total size.
  486.    `x=' is followed by the horizontal position of point, in columns
  487. from the left edge of the window.
  488.    If the buffer has been narrowed, making some of the text at the
  489. beginning and the end temporarily invisible, `C-x =' prints additional
  490. text describing the current visible range.  For example, it might say
  491.      Char: x (0170)  point=65986 of 563025(12%) <65102 - 68533>  x=44
  492. where the two extra numbers give the smallest and largest character
  493. position that point is allowed to assume.  The characters between
  494. those two positions are the visible ones.  *Note Narrowing::.
  495.    If point is at the end of the buffer (or the end of the visible
  496. part), `C-x =' omits any description of the character after point. 
  497. The output looks like
  498.      point=563026 of 563025(100%)  x=0
  499. File: emacs,  Node: Arguments,  Prev: Position Info,  Up: Basic
  500. Numeric Arguments
  501. =================
  502.    Any Emacs command can be given a "numeric argument".  Some commands
  503. interpret the argument as a repetition count.  For example, giving an
  504. argument of ten to the key `C-f' (the command `forward-char', move
  505. forward one character) moves forward ten characters.  With these
  506. commands, no argument is equivalent to an argument of one.  Negative
  507. arguments are allowed.  Often they tell a command to move or act
  508. backwards.
  509.    If your terminal keyboard has a META key, the easiest way to
  510. specify a numeric argument is to type digits and/or a minus sign while
  511. holding down the the META key.  For example,
  512.      M-5 C-n
  513. would move down five lines.  The characters `Meta-1', `Meta-2', and so
  514. on, as well as `Meta--', do this because they are keys bound to
  515. commands (`digit-argument' and `negative-argument') that are defined
  516. to contribute to an argument for the next command.
  517.    Another way of specifying an argument is to use the `C-u'
  518. (`universal-argument') command followed by the digits of the argument. 
  519. With `C-u', you can type the argument digits without holding down
  520. shift keys.  To type a negative argument, start with a minus sign. 
  521. Just a minus sign normally means -1.  `C-u' works on all terminals.
  522.    `C-u' followed by a character which is neither a digit nor a minus
  523. sign has the special meaning of "multiply by four".  It multiplies the
  524. argument for the next command by four.  `C-u' twice multiplies it by
  525. sixteen.  Thus, `C-u C-u C-f' moves forward sixteen characters.  This
  526. is a good way to move forward "fast", since it moves about 1/5 of a
  527. line in the usual size screen.  Other useful combinations are `C-u
  528. C-n', `C-u C-u C-n' (move down a good fraction of a screen), `C-u C-u
  529. C-o' (make "a lot" of blank lines), and `C-u C-k' (kill four lines).
  530.    Some commands care only about whether there is an argument, and not
  531. about its value.  For example, the command `M-q' (`fill-paragraph')
  532. with no argument fills text; with an argument, it justifies the text
  533. as well.  (*Note Filling::, for more information on `M-q'.)  Just
  534. `C-u' is a handy way of providing an argument for such commands.
  535.    Some commands use the value of the argument as a repeat count, but
  536. do something peculiar when there is no argument.  For example, the
  537. command `C-k' (`kill-line') with argument N kills N lines, including
  538. their terminating newlines.  But `C-k' with no argument is special: it
  539. kills the text up to the next newline, or, if point is right at the
  540. end of the line, it kills the newline itself.  Thus, two `C-k'
  541. commands with no arguments can kill a nonblank line, just like `C-k'
  542. with an argument of one.  (*Note Killing::, for more information on
  543. `C-k'.)
  544.    A few commands treat a plain `C-u' differently from an ordinary
  545. argument.  A few others may treat an argument of just a minus sign
  546. differently from an argument of -1.  These unusual cases will be
  547. described when they come up; they are always for reasons of
  548. convenience of use of the individual command.
  549. File: emacs,  Node: Undo,  Next: Minibuffer,  Prev: Basic,  Up: Top
  550. Undoing Changes
  551. ***************
  552.    Emacs allows all changes made in the text of a buffer to be undone,
  553. up to a certain amount of change (8000 characters).  Each buffer
  554. records changes individually, and the undo command always applies to
  555. the current buffer.  Usually each editing command makes a separate
  556. entry in the undo records, but some commands such as `query-replace'
  557. make many entries, and very simple commands such as self-inserting
  558. characters are often grouped to make undoing less tedious.
  559. `C-x u'
  560.      Undo one batch of changes (usually, one command worth) (`undo').
  561. `C-_'
  562.      The same.
  563.    The command `C-x u' or `C-_' is how you undo.  The first time you
  564. give this command, it undoes the last change.  Point moves to the text
  565. affected by the undo, so you can see what was undone.
  566.    Consecutive repetitions of the `C-_' or `C-x u' commands undo
  567. earlier and earlier changes, back to the limit of what has been
  568. recorded.  If all recorded changes have already been undone, the undo
  569. command prints an error message and does nothing.
  570.    Any command other than an undo command breaks the sequence of undo
  571. commands.  Starting at this moment, the previous undo commands are
  572. considered ordinary changes that can themselves be undone.  Thus, you
  573. can redo changes you have undone by typing `C-f' or any other command
  574. that will have no important effect, and then using more undo commands.
  575.    If you notice that a buffer has been modified accidentally, the
  576. easiest way to recover is to type `C-_' repeatedly until the stars
  577. disappear from the front of the mode line.  At this time, all the
  578. modifications you made have been cancelled.  If you do not remember
  579. whether you changed the buffer deliberately, type `C-_' once, and when
  580. you see the last change you made undone, you will remember why you
  581. made it.  If it was an accident, leave it undone.  If it was
  582. deliberate, redo the change as described in the preceding paragraph.
  583.    Whenever an undo command makes the stars disappear from the mode
  584. line, it means that the buffer contents are the same as they were when
  585. the file was last read in or saved.
  586.    Not all buffers record undo information.  Buffers whose names start
  587. with spaces don't; these buffers are used internally by Emacs and its
  588. extensions to hold text that users don't normally look at or edit. 
  589. Also, minibuffers, help buffers and documentation buffers don't record
  590. undo information.
  591.    At most 8000 or so characters of deleted or modified text can be
  592. remembered in any one buffer for reinsertion by the undo command. 
  593. Also, there is a limit on the number of individual insert, delete or
  594. change actions that can be remembered.
  595.    The reason the `undo' command has two keys, `C-x u' and `C-_', set
  596. up to run it is that it is worthy of a single-character key, but the
  597. way to type `C-_' on some keyboards is not obvious.  `C-x u' is an
  598. alternative you can type in the same fashion on any terminal.
  599. File: emacs,  Node: Minibuffer,  Next: M-x,  Prev: Undo,  Up: Top
  600. The Minibuffer
  601. **************
  602.    The "minibuffer" is the facility used by Emacs commands to read
  603. arguments more complicated than a single number.  Minibuffer arguments
  604. can be file names, buffer names, Lisp function names, Emacs command
  605. names, Lisp expressions, and many other things, depending on the
  606. command reading the argument.  The usual Emacs editing commands can be
  607. used in the minibuffer to edit the argument.
  608.    When the minibuffer is in use, it appears in the echo area, and the
  609. terminal's cursor moves there.  The beginning of the minibuffer line
  610. displays a "prompt" which says what kind of input you should supply and
  611. how it will be used.  Often this prompt is derived from the name of the
  612. command that the argument is for.  The prompt normally ends with a
  613. colon.
  614.    Sometimes a "default argument" appears in parentheses after the
  615. colon; it too is part of the prompt.  The default will be used as the
  616. argument value if you enter an empty argument (e.g., just type RET). 
  617. For example, commands that read buffer names always show a default,
  618. which is the name of the buffer that will be used if you type just RET.
  619.    The simplest way to give a minibuffer argument is to type the text
  620. you want, terminated by RET which exits the minibuffer.  You can get
  621. out of the minibuffer, canceling the command that it was for, by typing
  622. `C-g'.
  623.    Since the minibuffer uses the screen space of the echo area, it can
  624. conflict with other ways Emacs customarily uses the echo area.  Here
  625. is how Emacs handles such conflicts:
  626.    * If a command gets an error while you are in the minibuffer, this
  627.      does not cancel the minibuffer.  However, the echo area is needed
  628.      for the error message and therefore the minibuffer itself is
  629.      hidden for a while.  It comes back after a few seconds, or as
  630.      soon as you type anything.
  631.    * If in the minibuffer you use a command whose purpose is to print a
  632.      message in the echo area, such as `C-x =', the message is printed
  633.      normally, and the minibuffer is hidden for a while.  It comes back
  634.      after a few seconds, or as soon as you type anything.
  635.    * Echoing of keystrokes does not take place while the minibuffer is
  636.      in use.
  637. * Menu:
  638. * File: Minibuffer File.  Entering file names with the minibuffer.
  639. * Edit: Minibuffer Edit.  How to edit in the minibuffer.
  640. * Completion::          An abbreviation facility for minibuffer input.
  641. * Repetition::          Re-executing commands that used the minibuffer.
  642. File: emacs,  Node: Minibuffer File,  Next: Minibuffer Edit,  Prev: Minibuffer,  Up: Minibuffer
  643. Minibuffers for File Names
  644. ==========================
  645.    Sometimes the minibuffer starts out with text in it.  For example,
  646. when you are supposed to give a file name, the minibuffer starts out
  647. containing the "default directory", which ends with a slash.  This is
  648. to inform you which directory the file will be found in if you do not
  649. specify a directory.  For example, the minibuffer might start out with
  650.      Find File: /u2/emacs/src/
  651. where `Find File: ' is the prompt.  Typing `buffer.c' specifies the
  652. file `/u2/emacs/src/buffer.c'.  To find files in nearby directories,
  653. use `..'; thus, if you type `../lisp/simple.el', the file that you
  654. visit will be the one named `/u2/emacs/lisp/simple.el'. 
  655. Alternatively, you can kill with `M-DEL' the directory names you don't
  656. want (*note Words::.).
  657.    You can also type an absolute file name, one starting with a slash
  658. or a tilde, ignoring the default directory.  For example, to find the
  659. file `/etc/termcap', just type the name, giving
  660.      Find File: /u2/emacs/src//etc/termcap
  661. Two slashes in a row are not normally meaningful in Unix file names,
  662. but they are allowed in GNU Emacs.  They mean, "ignore everything
  663. before the second slash in the pair."  Thus, `/u2/emacs/src/' is
  664. ignored, and you get the file `/etc/termcap'.
  665.    If you set `insert-default-directory' to `nil', the default
  666. directory is not inserted in the minibuffer.  This way, the minibuffer
  667. starts out empty.  But the name you type, if relative, is still
  668. interpreted with respect to the same default directory.
  669. File: emacs,  Node: Minibuffer Edit,  Next: Completion,  Prev: Minibuffer File,  Up: Minibuffer
  670. Editing in the Minibuffer
  671. =========================
  672.    The minibuffer is an Emacs buffer (albeit a peculiar one), and the
  673. usual Emacs commands are available for editing the text of an argument
  674. you are entering.
  675.    Since RET in the minibuffer is defined to exit the minibuffer,
  676. inserting a newline into the minibuffer must be done with `C-o' or with
  677. `C-q LFD'.  (Recall that a newline is really the LFD character.)
  678.    The minibuffer has its own window which always has space on the
  679. screen but acts as if it were not there when the minibuffer is not in
  680. use.  When the minibuffer is in use, its window is just like the
  681. others; you can switch to another window with `C-x o', edit text in
  682. other windows and perhaps even visit more files, before returning to
  683. the minibuffer to submit the argument.  You can kill text in another
  684. window, return to the minibuffer window, and then yank the text to use
  685. it in the argument.  *Note Windows::.
  686.    There are some restrictions on the use of the minibuffer window,
  687. however.  You cannot switch buffers in it--the minibuffer and its
  688. window are permanently attached.  Also, you cannot split or kill the
  689. minibuffer window.  But you can make it taller in the normal fashion
  690. with `C-x ^'.
  691.    If while in the minibuffer you issue a command that displays help
  692. text of any sort in another window, then that window is identified as
  693. the one to scroll if you type `C-M-v' while in the minibuffer.  This
  694. lasts until you exit the minibuffer.  This feature comes into play if
  695. a completing minibuffer gives you a list of possible completions.
  696.    Recursive use of the minibuffer is supported by Emacs.  However, it
  697. is easy to do this by accident (because of autorepeating keyboards, for
  698. example) and get confused.  Therefore, most Emacs commands that use the
  699. minibuffer refuse to operate if the minibuffer window is selected.  If
  700. the minibuffer is active but you have switched to a different window,
  701. recursive use of the minibuffer is allowed--if you know enough to try
  702. to do this, you probably will not get confused.
  703.    If you set the variable `enable-recursive-minibuffers' to be
  704. non-`nil', recursive use of the minibuffer is always allowed.
  705. File: emacs,  Node: Completion,  Next: Repetition,  Prev: Minibuffer Edit,  Up: Minibuffer
  706. Completion
  707. ==========
  708.    When appropriate, the minibuffer provides a "completion" facility. 
  709. This means that you type enough of the argument to determine the rest,
  710. based on Emacs's knowledge of which arguments make sense, and Emacs
  711. visibly fills in the rest, or as much as can be determined from the
  712. part you have typed.
  713.    When completion is available, certain keys--TAB, RET, and SPC--are
  714. redefined to complete an abbreviation present in the minibuffer into a
  715. longer string that it stands for, by matching it against a set of
  716. "completion alternatives" provided by the command reading the argument. 
  717. `?' is defined to display a list of possible completions of what you
  718. have inserted.
  719.    For example, when the minibuffer is being used by `Meta-x' to read
  720. the name of a command, it is given a list of all available Emacs
  721. command names to complete against.  The completion keys match the text
  722. in the minibuffer against all the command names, find any additional
  723. characters of the name that are implied by the ones already present in
  724. the minibuffer, and add those characters to the ones you have given.
  725.    Case is normally significant in completion, because it is
  726. significant in most of the names that you can complete (buffer names,
  727. file names and command names).  Thus, `fo' will not complete to `Foo'.
  728.  When you are completing a name in which case does not matter, case
  729. may be ignored for completion's sake if the program said to do so.
  730. Completion Example
  731. ------------------
  732.    A concrete example may help here.  If you type `Meta-x au TAB', the
  733. TAB looks for alternatives (in this case, command names) that start
  734. with `au'.  There are only two: `auto-fill-mode' and `auto-save-mode'.
  735.  These are the same as far as `auto-', so the `au' in the minibuffer
  736. changes to `auto-'.
  737.    If you type TAB again immediately, there are multiple possibilities
  738. for the very next character--it could be `s' or `f'--so no more
  739. characters are added; but a list of all possible completions is
  740. displayed in another window.
  741.    If you go on to type `f TAB', this TAB sees `auto-f'.  The only
  742. command name starting this way is `auto-fill-mode', so completion
  743. inserts the rest of that.  You now have `auto-fill-mode' in the
  744. minibuffer after typing just `au TAB f TAB'.  Note that TAB has this
  745. effect because in the minibuffer it is bound to the function
  746. `minibuffer-complete' when completion is supposed to be done.
  747. Completion Commands
  748. -------------------
  749.    Here is a list of all the completion commands, defined in the
  750. minibuffer when completion is available.
  751. `TAB'
  752.      Complete the text in the minibuffer as much as possible 
  753.       (`minibuffer-complete').
  754. `SPC'
  755.      Complete the text in the minibuffer but don't add or fill out more
  756.      than one word (`minibuffer-complete-word').
  757. `RET'
  758.      Submit the text in the minibuffer as the argument, possibly
  759.      completing first as described below
  760.      (`minibuffer-complete-and-exit').
  761.      Print a list of all possible completions of the text in the
  762.      minibuffer (`minibuffer-list-completions').
  763.    SPC completes much like TAB, but never goes beyond the next hyphen
  764. or space.  If you have `auto-f' in the minibuffer and type SPC, it
  765. finds that the completion is `auto-fill-mode', but it stops completing
  766. after `fill-'.  This gives `auto-fill-'.  Another SPC at this point
  767. completes all the way to `auto-fill-mode'.  SPC in the minibuffer runs
  768. the function `minibuffer-complete-word' when completion is available.
  769.    There are three different ways that RET can work in completing
  770. minibuffers, depending on how the argument will be used.
  771.    * "Strict" completion is used when it is meaningless to give any
  772.      argument except one of the known alternatives.  For example, when
  773.      `C-x k' reads the name of a buffer to kill, it is meaningless to
  774.      give anything but the name of an existing buffer.  In strict
  775.      completion, RET refuses to exit if the text in the minibuffer
  776.      does not complete to an exact match.
  777.    * "Cautious" completion is similar to strict completion, except that
  778.      RET exits only if the text was an exact match already, not
  779.      needing completion.  If the text is not an exact match, RET does
  780.      not exit, but it does complete the text.  If it completes to an
  781.      exact match, a second RET will exit.
  782.      Cautious completion is used for reading file names for files that
  783.      must already exist.
  784.    * "Permissive" completion is used when any string whatever is
  785.      meaningful, and the list of completion alternatives is just a
  786.      guide.  For example, when `C-x C-f' reads the name of a file to
  787.      visit, any file name is allowed, in case you want to create a
  788.      file.  In permissive completion, RET takes the text in the
  789.      minibuffer exactly as given, without completing it.
  790.    The completion commands display a list of all possible completions
  791. in a window whenever there is more than one possibility for the very
  792. next character.  Also, typing `?' explicitly requests such a list.  The
  793. list of completions counts as help text, so `C-M-v' typed in the
  794. minibuffer scrolls the list.
  795.    When completion is done on file names, certain file names are
  796. usually ignored.  The variable `completion-ignored-extensions'
  797. contains a list of strings; a file whose name ends in any of those
  798. strings is ignored as a possible completion.  The standard value of
  799. this variable has several elements including `".o"', `".elc"',
  800. `".dvi"' and `"~"'.  The effect is that, for example, `foo' can
  801. complete to `foo.c' even though `foo.o' exists as well.  If the only
  802. possible completions are files that end in "ignored" strings, then
  803. they are not ignored.
  804.    Normally, a completion command that finds the next character is
  805. undetermined automatically displays a list of all possible
  806. completions.  If the variable `completion-auto-help' is set to `nil',
  807. this does not happen, and you must type `?' to display the possible
  808. completions.
  809. File: emacs,  Node: Repetition,  Prev: Completion,  Up: Minibuffer
  810. Repeating Minibuffer Commands
  811. =============================
  812.    Every command that uses the minibuffer at least once is recorded on
  813. a special history list, together with the values of the minibuffer
  814. arguments, so that you can repeat the command easily.  In particular,
  815. every use of `Meta-x' is recorded, since `M-x' uses the minibuffer to
  816. read the command name.
  817. `C-x ESC'
  818.      Re-execute a recent minibuffer command 
  819.      (`repeat-complex-command').
  820. `M-p'
  821.      Within `C-x ESC', move to previous recorded command
  822.      (`previous-complex-command').
  823. `M-n'
  824.      Within `C-x ESC', move to the next (more recent) recorded command
  825.      (`next-complex-command').
  826. `M-x list-command-history'
  827.      Display the entire command history, showing all the commands `C-x
  828.      ESC' can repeat, most recent first.
  829.    `C-x ESC' is used to re-execute a recent minibuffer-using command. 
  830. With no argument, it repeats the last such command.  A numeric
  831. argument specifies which command to repeat; one means the last one, and
  832. larger numbers specify earlier ones.
  833.    `C-x ESC' works by turning the previous command into a Lisp
  834. expression and then entering a minibuffer initialized with the text for
  835. that expression.  If you type just RET, the command is repeated as
  836. before.  You can also change the command by editing the Lisp
  837. expression.  Whatever expression you finally submit is what will be
  838. executed.  The repeated command is added to the front of the command
  839. history unless it is identical to the most recently executed command
  840. already there.
  841.    Even if you don't understand Lisp syntax, it will probably be
  842. obvious which command is displayed for repetition.  If you do not
  843. change the text, you can be sure it will repeat exactly as before.
  844.    Once inside the minibuffer for `C-x ESC', if the command shown to
  845. you is not the one you want to repeat, you can move around the list of
  846. previous commands using `M-n' and `M-p'.  `M-p' replaces the contents
  847. of the minibuffer with the next earlier recorded command, and `M-n'
  848. replaces them with the next later command.  After finding the desired
  849. previous command, you can edit its expression as usual and then
  850. resubmit it by typing RET as usual.  Any editing you have done on the
  851. command to be repeated is lost if you use `M-n' or `M-p'.
  852.    `M-p' is more useful than `M-n', since more often you will
  853. initially request to repeat the most recent command and then decide to
  854. repeat an older one instead.  These keys are specially defined within
  855. `C-x ESC' to run the commands `previous-complex-command' and
  856. `next-complex-command'.
  857.    The list of previous minibuffer-using commands is stored as a Lisp
  858. list in the variable `command-history'.  Each element is a Lisp
  859. expression which describes one command and its arguments.  Lisp
  860. programs can reexecute a command by feeding the corresponding
  861. `command-history' element to `eval'.
  862.